#pragma once

#include<iostream>
#include<assert.h>

namespace ZMH
{
	class string
	{
	public:
		typedef char* iterator;
		typedef const char* const_iterator;

		iterator begin()
		{
			return _val;
		}
		const_iterator begin() const
		{
			return _val;
		}
		iterator end()
		{
			return _val + _size;
		}
		const_iterator end() const
		{
			return _val + _size;
		}


		string();
		string(const char* str);
		string(const string& str);
		~string();
		string& operator=(const string& str);
		
		void append(const char* str);
		string& operator+=(char c);
		string& operator+=(const char* str);

		size_t size()const;
		size_t capacity()const;
		const char* c_str()const;

		void clear();
		void swap(string& s);
		bool empty()const;

		void resize(size_t n, char c = '\0');
		void reserve(size_t n = 0);

		char& operator[](size_t index);
		const char& operator[](size_t index)const;

		bool operator<(const string& s);
		bool operator<=(const string& s);
		bool operator>(const string& s);
		bool operator>=(const string& s);
		bool operator==(const string& s);
		bool operator!=(const string& s);

		size_t find(char c, size_t pos = 0) const;
		size_t find(const char* s, size_t pos = 0) const;

		string& insert(size_t pos, char c);
		string& insert(size_t pos, const char* str);
		string& erase(size_t pos, size_t len);

	private:
		char* _val;
		size_t _size;
		size_t _capacity;
	};


}
